Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middleware support #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Middleware support #12

wants to merge 2 commits into from

Conversation

georgski
Copy link

@georgski georgski commented Aug 6, 2014

In our project it turned out to particularly useful to pass configuration from middleware.

Example usage:
class JavascriptSettingsMiddleware(object):

    def process_request(self, request):
        request.javascript_settings = {}

    def process_template_response(self, request, response):
        request.javascript_settings['api_url_friend'] = '/api/v1/friend/'

        return response

@tomwys
Copy link
Contributor

tomwys commented Sep 14, 2014

Sorry you have to wait so long for the response. In fact I didn't know there is pull request (probably missed email from Github).

Your use case makes sens. Originally we were thinking that django-javscript-settings should be for static configuration only, but I can't see reason, why not allow configuration form Middleware.

I have one suggestion. I thing that we shouldn't hardcode to codebase all use cases we have, but rather make code more flexible, so use cases could be configured. In this case I propose to extend javascript_settings template tag with parameter, so you could use it like this:

{% javascript_settings request.javascript_settings %}

In this way your use case is fulfilled, but not hardcoded into codebase.

Are you interested in implementing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants